package com.zxhysy.log.annotation.advisor;

import org.springframework.aop.Pointcut;
import org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor;

import java.util.Objects;

/**
 * 日志操作顾问, 配置拦截端点
 * @author zhangxinhong
 * @since 2021/9/23 14:56
 */
public class BeanFactoryLogSourceAdvisor extends AbstractBeanFactoryPointcutAdvisor {

    /**
     * 切点
     */
    private LogSourcePointcut logSourcePointcut;

    public void setPointcut(LogSourcePointcut logSourcePointcut) {
        this.logSourcePointcut = logSourcePointcut;
    }

    @Override
    public Pointcut getPointcut() {
        return this.logSourcePointcut;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        BeanFactoryLogSourceAdvisor that = (BeanFactoryLogSourceAdvisor) o;
        return Objects.equals(logSourcePointcut, that.logSourcePointcut);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), logSourcePointcut);
    }
}
